How to change the data type from bytea[] to bytea of column in PostgreSQL?
NickName:heer24 Ask DateTime:2019-11-26T13:30:26

How to change the data type from bytea[] to bytea of column in PostgreSQL?

I am new to PostgreSQL. I want to change one of my column datatype from bytea[] to bytea in Postgres. I tried the following query but it is giving the error cannot cast type bytea[] to bytea:

ALTER TABLE table_name
ALTER COLUMN COLUMN_NAME TYPE bytea USING COLUMN_NAME::bytea;

Does anyone know how to do this?

Copyright Notice:Content Author:「heer24」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59044328/how-to-change-the-data-type-from-bytea-to-bytea-of-column-in-postgresql

More about “How to change the data type from bytea[] to bytea of column in PostgreSQL?” related questions

How to change the data type from bytea[] to bytea of column in PostgreSQL?

I am new to PostgreSQL. I want to change one of my column datatype from bytea[] to bytea in Postgres. I tried the following query but it is giving the error cannot cast type bytea[] to bytea: ALTER

Show Detail

How to change column type from oid to bytea in PostgreSQL

At first place, I got this error: org.postgresql.util.PSQLException: ERROR: column xxxx is of type oid but expression is of type bytea Hint: You will need to rewrite or cast the expression. Posit...

Show Detail

PostgreSQL: from OID to Bytea

We have decided to move from OIDs in our PostgreSQL 9.0 database and use bytea columns instead. I'm trying to copy the data from one column to the other, but I can't figure out the right query. Thi...

Show Detail

Postgresql - alter column type from oid to bytea with data retention

Now I'm developing application that uses hibernate + postgresql to persist data. We need to store a number of serializable HashMaps, so LOB (oid) was used for this purpose. But due to some problems...

Show Detail

How to insert (array) data into a PostgreSQL bytea column?

How can I store the following data structure: byte[] number = new byte[1000]; in bytea column in PostgreSQL with INSERT INTO blobT command? CREATE TABLE blobT ( blob bytea ); What ...

Show Detail

Read PostgreSQL Bytea column in Ruby

I am trying to read a bytea column from PostgreSQL using Ruby. The problem is that it returns the hex encoded string of the bytea value. I would like it to return exactly the same as if I would ope...

Show Detail

Get size for Bytea column in postgreSQL

I have table for store file information. File content is stored in column (column datatype is bytea in PostgreSQL). Now I want to get file content size, based on bytea column data. In SQL Server,...

Show Detail

unique constraint on Bytea data type on Postgresql

I'm storing images on the Bytea data type of Postgresql, I do understand that this is not recommend, but I do think the benefits of having the images organized out-wights the disadvantages for my u...

Show Detail

How can I resolve "invalid input sequence for type bytea" in a Rails migration of a pg column from text to binary (bytea)?

I have a Rails application with a pg database, and the type of the 'input' column in one of my tables is text. I have discovered that some of my input files aren't any particular text encoding, so ...

Show Detail

How to convert bit type to bytea type in Postgresql

I want to convert bit type into bytea in postgresql. Like this. select (b'1010110011001100' & b'1011000011110000')::bytea; However, error occured ERROR: cannot cast type bit to bytea LINE 1:

Show Detail